package com.example.houtai.controller;


import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.example.houtai.service.ISysRoleService;
import com.org.dto.RoleDto;
import com.org.vo.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * <p>
 * 角色 前端控制器
 * </p>
 *
 * @author 龚梦
 * @since 2021-03-22
 */

/**
 * 角色
 */
@RestController
@RequestMapping("/sys/role")
public class SysRoleController {
    /**
     * 郝政博
     */
    @Autowired
    private ISysRoleService service;

    @RequestMapping("list")
    public ResultEntity list(@RequestBody RoleDto roleDto) {
        System.err.println(roleDto);
        return ResultEntity.ok("200", "success", service.listAll(roleDto));
    }

    @RequestMapping("insert")
    public ResultEntity insert(@RequestBody RoleDto roleDto) {
        return service.insert(roleDto);
    }

    @RequestMapping("edit")
    public ResultEntity edit(@RequestBody RoleDto roleDto) {
        return service.edit(roleDto);
    }

    @RequestMapping("delete")
    public ResultEntity delete(@RequestBody RoleDto roleDto) {
        return service.delete(roleDto);
    }

    @RequestMapping("selRoleByDeptId")
    public ResultEntity selRoleByDeptId(@RequestBody Map<String, Object> map) {
        System.err.println(map);
        return service.selRoleByDeptId(Integer.parseInt(map.get("deptId").toString()));
    }
}
